<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/view/common/common.jsp"%>
	<script type="text/javascript">
		function searchData() {
			$('#tab').datagrid('load',serializeForm($('#mySearchForm')));
		}
		
		/* 0-待收款，1-待付款，2-待确认，3-已取消，4-已成交 */
		function formatStatusData(val, row){
			if (val == '1') {
				return '通过';
			} else if(val == '-1') {
				return '驳回';
			}else if(val == '0'){
				return '待审核';
			}else{
				return '未知';
			}
		}
		
		function formatterUrl(value,row,index){
	            return '<a  href="javascript:;" onclick="go(this)" data_url='+value+'>查看</a>';
	     } 
		
		function go(obj){
			var url = $(obj).attr("data_url")
			$("#url").attr('src',"${picPath}"+url);
			$("#system_user_addDialog").dialog({
				modal : true,
				title : '图片凭证',
				cache : false,
				shadow:false,
				closed : false
			});
		}
		
		function handlerAppeal(status) {//通过或者驳回
			var rows = $('#tab').datagrid('getSelections');
			if (rows.length != 1) {
				$.messager.alert('消息', '请选择一条数据!', 'info');
				return false;
			}
			if(rows[0].status!=0){
				$.messager.alert('消息', '操作无效!', 'info');
				return false;
			}
			var url ='${ctx}/tOrder/handlerAppeal.do';	
			$.post(url,{"id":rows[0].id,"status":status},function(result){
				var result = eval('(' + result + ')');
				if (result.isSuc) {
					$.messager.alert('消息', result.msg, 'info');
					$('#tab').datagrid('reload');
				} else {
					$.messager.alert('错误', result.msg, 'error');
				}
			}) 
		}
	</script>

</head>
<body>

<div class="easyui-panel"  fit="true">
	<div id="jqueryToolbar" style="padding:auto;height:auto">
		<div style="margin-top:5px; padding-bottom:8px; border-bottom:1px solid #ccc;">
			<form id="mySearchForm" action="" method="Post">
				订单号:<input type="text" id="order_no" name="orderCode" class="easyui-textbox"  style="width: 140px; height: 25px;"/>
				状态:
				<!-- 0-待审核，1-通过，-1-驳回-->
				<select name="status" id="status" class="easyui-combobox" style="width:80px;height: 25px;" data-options="panelHeight:'auto'">
					<option value="">全部</option>
					<option value=0>待审核</option>
					<option value=1>通过</option>
					<option value=-1>驳回</option>
				</select>
				申诉用户:<input type="text" id="order_no" prompt="手机号码或者昵称" name="userInfo" class="easyui-textbox"  style="width: 140px; height: 25px;"/>
				被申诉者用户:<input type="text" id="order_no" prompt="手机号码或者昵称" name="otherUserInfo" class="easyui-textbox"  style="width: 140px; height: 25px;"/>
				<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="searchData()">查询</a>
			</form>
		</div>
	</div>
	
	<div id="system_user_list_tb" style="height: auto; padding-left: auto;">
		<a href="#" class="easyui-linkbutton" onclick="handlerAppeal(1)" data-options="iconCls:'icon-edit',plain:true">通过</a>
		<a href="#" class="easyui-linkbutton" onclick="handlerAppeal(-1)" data-options="iconCls:'icon-edit',plain:true">驳回</a>
	</div>
	
	<div id="system_user_addDialog"  class="easyui-dialog"  data-options="closed:true"  buttons="#addButs1">
	   <div>
	        <a>
	            <img src="" style='width : 500px;height : 500px;' id='url'/>
	        </a>
	    </div>
	</div>
	

	<table id="tab" class="easyui-datagrid"  fit="true" style="height:350px;width:auto" url="${ctx}/bOrder/getOrderAppealList.do"
		   rownumbers="true" pagination="true" pagePosition="top" singleSelect="true">
		<thead>
		<tr>
			<th field="id" width="60" align="center">主键</th>
			<th field="order_code"  width="160" align="center">订单号</th>
			<th field="img_url" width="80" align="center" data-options="formatter:formatterUrl">图片凭证</th>
			<th field="remark" width="250" align="center">备注</th>
			<th field="status" width="60" align="center" data-options="formatter:formatStatusData" >状态</th>
			<th field="userInfo" width="250" align="center">申诉用户</th>
			<th field="otherUserInfo" width="250" align="center">被申诉用户</th>
			<th field="create_time" width="150" align="center">创建时间</th>
		</tr>
		</thead>
	</table>
</div>
</body>
</html>
